using System.Collections.Generic;

namespace Commons.Daos
{
	public abstract class SQLDao<T> : ISQLDao, ICacheControl
	{
		protected T cache;

		public DaoSupport DaoSupport { protected get; set; }

		public virtual void UpgradeTable(int oldVersion)
		{
			foreach (string sql in GetUpgradeSqls(oldVersion))
			{
				DaoSupport.Execute(sql);
			}
		}

		public virtual void ClearCache()
		{
			cache = default(T);
		}

		protected virtual IEnumerable<string> GetUpgradeSqls(int oldVersion)
		{
			yield break;
		}
	}
}